
export const SET_PAGE_TITLE = "SET_PAGE_TITLE";
export const SET_INFO_LIST = "SET_INFO_LIST";
export const DEL = "DEL";
export const INCRE = "INCRE";
export const SET = "SET";
 
 
export function setPageTitle(data){
    return {type: SET_PAGE_TITLE, data: data}
}
 
export function setInfoList (data) {
  return (dispatch, getState) => {
    // 使用fetch实现异步请求
    // 请求发起前可以先dispatch一个加载开始状态
    // 例如 dispatch({ type: SET_LOADING_TYPE, data: "loading" })
    window.fetch('/manifest.json', {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(res => {
        return res.json()
    }).then(res => {
        let { code } = res
        if (code === 0) {
            dispatch({ type: SET_INFO_LIST, data: res })
        }
        // 请求结束可以dispatch一个加载结束状态
        // 例如 dispatch({ type: SET_LOADING_TYPE, data: "loaded" })
        // 还可以区分一下成功或者失败
    })
  }
}

export function setCount(type){
    return{type}
}

export function setUserInfo(type,data){
    return{type,data}
}